﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using DATN.DataAccess;
using DATN.Entities;

namespace DATN.Business
{
    public class LichCongTacBusiness
    {
        public List<Lichcongtac> GetAllLichCongTacByDate(string dateLCT)
        {
            LichCongTacDataAccess data = new LichCongTacDataAccess();

            return data.GetAllLichCongTacByDate(dateLCT);
        }

        public List<Lichcongtac> GetAllLichCongTacByDateVaNguoiDangNhap(string dateLCT, string thanhPhan)
        {
            LichCongTacDataAccess data = new LichCongTacDataAccess();

            return data.GetAllLichCongTacByDateVaNguoiDangNhap(dateLCT, thanhPhan);
        }

        public bool InsertLich(Lichcongtac lich)
        {
            if (string.IsNullOrEmpty(lich.Noi_dung)) return false;
            var lichDataAccess = new LichCongTacDataAccess();
            try
            {
                return lichDataAccess.InsertLich(lich);
            }
            catch (SqlException exception)
            {
                Console.WriteLine(exception.ToString());
            }
            return false;
        }

        public Lichcongtac GetAllLichCongTacByID(int id)
        {
            LichCongTacDataAccess data = new LichCongTacDataAccess();

            return data.GetLichCongTacByID(id);
        }

        public bool UpdatetLich(Lichcongtac lich)
        {
            if (string.IsNullOrEmpty(lich.Noi_dung)) return false;
            var lichDataAccess = new LichCongTacDataAccess();
            try
            {
                return lichDataAccess.UpdateLich(lich);
            }
            catch (SqlException exception)
            {
                Console.WriteLine(exception.ToString());
            }
            return false;
        }
    }
}
